package one.stand.dto;

import cn.hutool.core.util.CharUtil;
import cn.hutool.core.util.StrUtil;
import lombok.Builder;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;

@Data
@Builder
public class DictDto implements Serializable {
    private static final long serialVersionUID = 1L;

    private Integer id;
    private Integer dictId;
    private String type;
    private String name;
    private String value;
    private String memo;

    public Integer getValueInteger() {
        return getValueInteger(null);
    }

    public Integer getValueInteger(Integer defaultValue) {
        return Objects.nonNull(value) ? Integer.valueOf(value) : defaultValue;
    }

    public List<String> getValueList() {
        return StringUtils.isNoneBlank(value) ? StrUtil.split(value, CharUtil.COMMA) : null;
    }
}
